class PopulateMixin(object):
    def populate(self, obj):
        props = {}
        if isinstance(obj, dict):
            for key in obj:
                if hasattr(self, str(key)) and self._is_populate(str(key)):
                    props[str(key)] = obj[key]
        elif isinstance(obj, type):
            for key in self.__dict__:
                if hasattr(obj, key) and self._is_populate(key):
                    props[key] = getattr(obj, key)

        self._set_props(props)

    def _is_populate(self, field: str):
        return True if field else False

    def _set_props(self, props):
        for k in props:
            setattr(self, k, props[k])

    def _cross_setattr(self, props):
        """
        Be careful not to use it alone
        example:
            class NewObject(PopulateMixin):
                def _set_props(self, props):
                    self._cross_setattr(props)
        """
        self.__dict__.update(props)

